package cn.lili.xiaoran.service.impl;

import cn.lili.xiaoran.entity.LiQuestionsFabulous;
import cn.lili.xiaoran.mapper.LiQuestionsFabulousMapper;
import cn.lili.xiaoran.service.LiQuestionsFabulousService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;

/**
 * 喜欢表(LiQuestionsFabulous)表服务实现类
 *
 * @author makejava
 * @since 2022-08-14 22:05:11
 */
@Service("liQuestionsFabulousService")
public class LiQuestionsFabulousServiceImpl extends ServiceImpl<LiQuestionsFabulousMapper, LiQuestionsFabulous> implements LiQuestionsFabulousService {
    @Resource
    private LiQuestionsFabulousMapper liQuestionsFabulousDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public LiQuestionsFabulous queryById(Integer id) {
        return this.liQuestionsFabulousDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param liQuestionsFabulous 筛选条件
     * @param pageRequest         分页对象
     * @return 查询结果
     */
    @Override
    public Page<LiQuestionsFabulous> queryByPage(LiQuestionsFabulous liQuestionsFabulous, PageRequest pageRequest) {
        long total = this.liQuestionsFabulousDao.count(liQuestionsFabulous);
        return new PageImpl<>(this.liQuestionsFabulousDao.queryAllByLimit(liQuestionsFabulous, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param liQuestionsFabulous 实例对象
     * @return 实例对象
     */
    @Override
    public LiQuestionsFabulous insert(LiQuestionsFabulous liQuestionsFabulous) {
        this.liQuestionsFabulousDao.insert(liQuestionsFabulous);
        return liQuestionsFabulous;
    }

    /**
     * 修改数据
     *
     * @param liQuestionsFabulous 实例对象
     * @return 实例对象
     */
    @Override
    public LiQuestionsFabulous update(LiQuestionsFabulous liQuestionsFabulous) {
        this.liQuestionsFabulousDao.update(liQuestionsFabulous);
        return this.queryById(liQuestionsFabulous.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.liQuestionsFabulousDao.deleteById(id) > 0;
    }
}
